import { _decorator, Component, Sprite, UITransform } from 'cc'
import { DataCenter } from '../../Runtime/DataCenter'
const { ccclass, property } = _decorator

@ccclass('TileItem')
export class TileItem extends Component {
  init(spriteFrame, row, col) {
    const { TILE_WIDTH, TILE_HEIGHT } = DataCenter
    const sprite = this.node.addComponent(Sprite)
    const transform = this.getComponent(UITransform)
    sprite.spriteFrame = spriteFrame
    this.node.setPosition(row * TILE_WIDTH, -col * TILE_HEIGHT)
    transform.width = TILE_WIDTH
    transform.height = TILE_HEIGHT
  }
}
